package com.craftcomputing.client.Pages;

import com.craftcomputing.client.RoundedPanel;
import com.craftcomputing.client.Header.Header;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Widget;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.HTML;
import com.google.gwt.user.client.ui.Image;
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
import com.google.gwt.user.client.ui.HasVerticalAlignment;
import com.google.gwt.user.client.ui.VerticalPanel;

public class WebPage extends Composite {
	protected static VerticalPanel bodyPanel = new VerticalPanel();
	public WebPage() {
		final Header header = new Header();
		final VerticalPanel verticalPanel = new VerticalPanel();
		final HorizontalPanel horizontalPanel = new HorizontalPanel();
		initWidget(horizontalPanel);
		horizontalPanel.add(verticalPanel);
		verticalPanel.setWidth("800px");
		horizontalPanel.setCellWidth(verticalPanel, "800px");
		horizontalPanel.setCellHorizontalAlignment(verticalPanel, HasHorizontalAlignment.ALIGN_CENTER);
		horizontalPanel.setWidth("100%");
		setWidth("100%");
		
		verticalPanel.add(header);
		verticalPanel.add(bodyPanel);

		final VerticalPanel tmp = new VerticalPanel();
		final HorizontalPanel footer = new HorizontalPanel();
		footer.setStyleName("gwt-Header");
		footer.setWidth("800px");
		//footer.setSpacing(8);

		final RoundedPanel roundedPanel = new RoundedPanel(tmp, RoundedPanel.BOTTOM, 9);
		roundedPanel.setCornerColor("#f07d1e");
		verticalPanel.add(footer);
		verticalPanel.add(roundedPanel);

		final Image im = new Image("http://i.creativecommons.org/l/by-nc-sa/3.0/us/88x31.png");
		im.setStyleName("gwt-Footer");
		final HTML html = new HTML("<font size=-2>Craft Computing is licensed under a " + 
				"<a rel='license' href='http://creativecommons.org/licenses/by-nc-sa/3.0/us/' target='_blank'>" + 
				"Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License </a></font>");
		footer.add(im);
		footer.add(html);
		html.setStyleName("gwt-Footer");
		footer.setCellVerticalAlignment(html, HasVerticalAlignment.ALIGN_MIDDLE);
		footer.setCellWidth(html, "100%");
		footer.setCellHorizontalAlignment(html, HasHorizontalAlignment.ALIGN_LEFT);
		//html.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
		//footer.setCellVerticalAlignment(html, HasVerticalAlignment.ALIGN_MIDDLE);
		//footer.setCellHorizontalAlignment(html, HasHorizontalAlignment.ALIGN_LEFT);
	}
	public void add(Widget w){bodyPanel.add(w);}
	public void clear(){bodyPanel.clear();}
}
